<template>
    <div>
        <!-- 有子产品，统一发版的-->
        <HCollapse collapse @change="handleLoadData">
            <template #title>
                <flexbox style="color: #70798b">
                    <span class="font-w-b">{{ detail.versionNumber }} </span>
                    <flexbox style="flex: 1; white-space: nowrap; overflow: hidden" justify="center">
                        <span class="text-bre1"> {{ detail.startTime || '暂无' }}~{{ detail.onlineTime || '暂无' }} </span>
                    </flexbox>
                </flexbox>
            </template>
            <div v-for="item of subVersionSystemList" :key="item.id">
                <!-- 每一个具体产品或者子产品 -->
                <SubVersionSystemItem :systemDetail="item" :disabled="disabled" :signPostShowType="signPostShowType" @success="handleLoadData" />
            </div>
        </HCollapse>
    </div>
</template>

<script lang="ts">
import SubVersionSystemItem from './SubVersionSystemItem.vue';
import api from '@/api';
import HCollapse from '../components/HCollapse.vue';
import { defineComponent, reactive, toRefs, getCurrentInstance } from 'vue';
export default defineComponent({
    components: {
        HCollapse,
        SubVersionSystemItem
    },
    props: {
        detail: {
            type: Object,
            default: () => ({})
        },
        lubiaoDetail: {
            type: Object,
            default: () => ({})
        },
        signPostShowType: {
            type: String,
            default: ''
        },
        subVersionInfo: {
            type: Object,
            default: () => ({})
        },
        disabled: {
            type: Boolean,
            default: false
        }
    },
    emits: ['success'],
    setup(props, { emit }) {
        const instance: any = getCurrentInstance();
        const state = reactive<any>({
            subVersionSystemList: []
        });
        const handleLoadData = async (expanded) => {
            if (expanded) {
                const query = {
                    versionNumber: props.detail.versionNumber,
                    catalogCode: props.detail.catalogCode
                };
                const { success, moule } = await api.versionModel.findByVerNoAndCatalogCode(query);
                if (success) {
                    state.subVersionSystemList = [...moule];
                }
            }
        };
        const handleSuccess = () => {
            emit('success');
        };
        // 更新展开接口
        instance.proxy.$mitt.on('taskRequireList-subVersionSystemList-loadData', () => {
            handleLoadData(true);
        });
        return {
            ...toRefs(state),
            handleLoadData,
            handleSuccess
        };
    }
});
</script>
<style lang="less" scoped>
::v-deep(.ant-collapse-content > .ant-collapse-content-box) {
    padding-bottom: 2px !important;
}
</style>